package com.event.ingestion.common;

import org.apache.commons.lang.ArrayUtils;

/**
 * @author ZzHh
 * @Classname Parsable
 * @Description TODO
 * @Date:2020/06/18 11:35
 * @Create by IntelliJ IDEA
 **/

public interface Parsable<T> {
    Boolean isHeader(String [] fields);
    Boolean isValid(String [] fields);
    //新增一个empty方法
    default Boolean isEmpty(String [] fields,int[] indexes){
     Boolean empty=false;
     //check
        if (fields !=null && fields.length>0){
             //循环
            for (int i = 0; i <fields.length ; i++) {
                if (indexes !=null && ArrayUtils.contains(indexes,i)){
                        empty |=(fields[i] == null || fields[i].trim().length() <=0);
                }
            }
        }

     return empty;
    }

    //数据格式变换
    T parse(String[] fields);
}
